package com.sunnada.edu.system.sysdict.service;

import java.util.HashMap;
import java.util.List;
import java.util.UUID;

import com.sunnada.edu.system.pub.common.AppContext;
import com.sunnada.edu.system.pub.common.MD5;
import com.sunnada.edu.system.pub.dao.PubDao;

public class SysDictMethods {
	
	public static List getDictTypeList(HashMap<String, String> params){	
		PubDao dao = AppContext.getInstance().getPubDao();
		String userId=params.get("userId");
		String sql="SELECT T.TYPE,T.NAME FROM S_DICT_TYPE T ";
		return dao.selectList(sql);	
	}
	
	public static List getDictListByType(HashMap<String, String> params){	
		PubDao dao = AppContext.getInstance().getPubDao();
		String dicType=params.get("dicType");
		String sql="select t.rec_key,t.rec_value from s_dict t where t.rec_type='"+dicType+"' ";
		return dao.selectList(sql);	
	}

	public static int typeAdd(HashMap<String, String> params) {
		PubDao dao = AppContext.getInstance().getPubDao();
		String type=params.get("type");
		String name=params.get("name");
		String recId = UUID.randomUUID().toString();
		String sql="insert into S_DICT_TYPE(REC_ID,TYPE,NAME) VALUES('"+recId+"','"+type+"','"+name+"')";
		return dao.insert(sql);
		
	}

}
